package plus.xj17520.base.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @projectName: pethomeProject
 * @package: plus.xj17520.org.utils
 * @className: EmailUtil
 * @author: XiaoJue
 * @description: TODO
 * @date: 2022/5/29 11:54
 * @version: 1.0
 */
@Component
public class EmailUtil {

    @Autowired
    private JavaMailSender javaMailSender;

    public void send(String addresser, String subject, String text, String to) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom(addresser);
        //邮件主题
        mailMessage.setSubject(subject);
        //邮件内容
        mailMessage.setText(text);
        //收件人
        mailMessage.setTo(to);

        javaMailSender.send(mailMessage);
    }


}
